package top.lrshuai.websocket.user.service.impl;

import org.springframework.transaction.annotation.Transactional;
import top.lrshuai.websocket.user.entity.User;
import top.lrshuai.websocket.user.mapper.UserMapper;
import top.lrshuai.websocket.user.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author rstyro
 * @since 2021-03-31
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Override
    @Transactional
    public void testTrans() {
        boolean save = this.save(new User().setAge(25).setCreateTime(LocalDateTime.now()).setInfo("this is info").setNickName("rstyro"));
        System.out.println("----------------------");
        System.out.println("age="+1/0);
        User byId = this.getById(1);
        byId.setCreateTime(LocalDateTime.now());
        byId.setInfo("aaaaaaaaaaa");
        this.updateById(byId);
    }
}
